package com.janko.springbootbase.basic.enumTest;

import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * 车辆种类
 */
@Getter
public enum VehicleType  {
    KECHE(0, "客车", "A0"),
    XIANGSHIHUOCHE(1, "厢式货车", "H3"),
    GUANSHIHUOCHE(2, "罐式货车", "T11");

    private final int value;
    private final String describe;
    private final String sinosig;

    VehicleType(int value, String describe, String sinosig) {
        this.value = value;
        this.describe = describe;
        this.sinosig = sinosig;
    }

    public static VehicleType findEnumByValue(Integer code) {

        for ( VehicleType vehicleType :  VehicleType.values()) {
            if (vehicleType.getValue().equals(code)) {
                return vehicleType;
            }

        }
        throw new IllegalArgumentException("code is not support");
    }

    public Integer getValue() {
        return this.value;
    }

    @JsonValue
    @Override
    public String toString() {
        return this.getValue().toString();
    }
}
